﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
namespace AnyOffice.general.vehicle
{
    public partial class usage_detail : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int usageId = (Request.QueryString["usage_id"] == null) ? 0 : int.Parse(Request.QueryString["usage_id"].ToString());
            DataTable table = new VehicleUsageDao().SelectByUsageId(base.Conn, usageId);
            if (table.Rows.Count == 0)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowPromptClose("无相应记录");
            }
            else
            {
                if (table.Rows[0]["Number"] != DBNull.Value)
                {
                    this.litNumber.Text = table.Rows[0]["Number"].ToString();
                }
                if (table.Rows[0]["Driver"] != DBNull.Value)
                {
                    this.litDriver.Text = table.Rows[0]["Driver"].ToString();
                }
                if (table.Rows[0]["ProposerName"] != DBNull.Value)
                {
                    this.litProposerName.Text = table.Rows[0]["ProposerName"].ToString();
                }
                if (table.Rows[0]["RequestTime"] != DBNull.Value)
                {
                    this.litRequestTime.Text = table.Rows[0]["RequestTime"].ToString();
                }
                if (table.Rows[0]["Person"] != DBNull.Value)
                {
                    this.litPerson.Text = table.Rows[0]["Person"].ToString();
                }
                if (table.Rows[0]["DeptName"] != DBNull.Value)
                {
                    this.litDeptName.Text = table.Rows[0]["DeptName"].ToString();
                }
                if (table.Rows[0]["Reason"] != DBNull.Value)
                {
                    this.litReason.Text = table.Rows[0]["Reason"].ToString();
                }
                if (table.Rows[0]["StartTime"] != DBNull.Value)
                {
                    this.litStartTime.Text = table.Rows[0]["StartTime"].ToString();
                }
                if (table.Rows[0]["EndTime"] != DBNull.Value)
                {
                    this.litEndTime.Text = table.Rows[0]["EndTime"].ToString();
                }
                if (table.Rows[0]["Destination"] != DBNull.Value)
                {
                    this.litDestination.Text = table.Rows[0]["Destination"].ToString();
                }
                if (table.Rows[0]["Mileage"] != DBNull.Value)
                {
                    this.litMileage.Text = table.Rows[0]["Mileage"].ToString();
                }
                if (table.Rows[0]["OperatorName"] != DBNull.Value)
                {
                    this.litOperatorName.Text = table.Rows[0]["OperatorName"].ToString();
                }
                if (table.Rows[0]["Remark"] != DBNull.Value)
                {
                    this.litRemark.Text = table.Rows[0]["Remark"].ToString();
                }
                string str = table.Rows[0]["Status"].ToString();
                if (str != null)
                {
                    if (!(str == "0"))
                    {
                        if (!(str == "1"))
                        {
                            if (str == "2")
                            {
                                this.litStatus.Text = "未准";
                            }
                            return;
                        }
                    }
                    else
                    {
                        this.litStatus.Text = "待批";
                        return;
                    }
                    if ((Convert.ToDateTime(table.Rows[0]["StartTime"].ToString()) < DateTime.Now) && (Convert.ToDateTime(table.Rows[0]["EndTime"].ToString()) > DateTime.Now))
                    {
                        this.litStatus.Text = "进行中";
                    }
                    else if (Convert.ToDateTime(table.Rows[0]["EndTime"].ToString()) > DateTime.Now)
                    {
                        this.litStatus.Text = "已结束";
                    }
                    else
                    {
                        this.litStatus.Text = "已准";
                    }
                }
            }
        } 

    }
}
